OPTION(OTB_USE_CPACK "Generate installer using CPack" OFF)
MARK_AS_ADVANCED(OTB_USE_CPACK)

IF(OTB_USE_CPACK)

SET(CPACK_PACKAGE_NAME "Monteverdi" CACHE STRING "Package name")
MARK_AS_ADVANCED(CPACK_PACKAGE_NAME)

SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Monteverdi Application")
MARK_AS_ADVANCED(CPACK_PACKAGE_DESCRIPTION_SUMMARY)

SET(CPACK_PACKAGE_VERSION  "${Monteverdi_VERSION_STRING}")
SET(CPACK_PACKAGE_VERSION_MAJOR "${Monteverdi_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${Monteverdi_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${Monteverdi_VERSION_PATCH}")

SET(CPACK_PACKAGE_CONTACT "contact@orfeo-toolbox.org" CACHE STRING  "Orfeo toolbox contact email")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${Monteverdi_SOURCE_DIR}/Description.txt")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Monteverdi-${Monteverdi_VERSION_MAJOR}.${Monteverdi_VERSION_MINOR}")
SET(CPACK_RESOURCE_FILE_LICENSE "${Monteverdi_SOURCE_DIR}/Copyright/OTBCopyright.txt")

# http://www.vtk.org/Bug/view.php?id=7828
# Need to use the CPACK_PACKAGE_EXECUTABLES
# otherwise the shortcut in the menu will not
# appear.
SET(CPACK_PACKAGE_EXECUTABLES "monteverdi" "Monteverdi application")

# Manage dependencies between components
SET(CPACK_COMPONENT_DEVELOPMENT_DEPENDS Runtime)
SET(CPACK_COMPONENT_RUNTIME_DEPENDS Resources)

SET(CPACK_COMPONENT_RUNTIME_REQUIRED ON)
SET(CPACK_COMPONENT_RESOURCES_REQUIRED ON)
SET(CPACK_COMPONENT_RESOURCES_HIDDEN ON)

SET(CPACK_COMPONENT_RUNTIME_DESCRIPTION "Monteverdi application")

# Don't packge the Developement component
SET(CPACK_COMPONENTS_ALL "Runtime;Resources;Unspecified")

IF( APPLE )
  ADD_SUBDIRECTORY( MacOS )
ENDIF( APPLE )

IF( WIN32 AND NOT UNIX )
  ADD_SUBDIRECTORY( Windows )
ENDIF( WIN32 AND NOT UNIX )

INCLUDE(InstallRequiredSystemLibraries)
INCLUDE(CPack)

ELSE(OTB_USE_CPACK)

# CPack is not used for GNU/Linux packaging
IF( UNIX AND NOT APPLE )
  ADD_SUBDIRECTORY( Linux )
ENDIF( UNIX AND NOT APPLE )

ENDIF(OTB_USE_CPACK)
